import 'dart:convert';

import 'package:flutter/services.dart';
import 'package:flutter_app/model/song_model.dart';
import 'package:get/get.dart';

class SongsState {
  RxList<SongItem> songList = SongList([]).list.obs;

  SongsState() {
    getData();
  }

  Future getData() async {
    String data = await rootBundle.loadString("assets/data/song.json");
    Map<String, dynamic> result = jsonDecode(data);
    //将数据转为实体类
    SongList songListModel = SongList.fromJson(result['data']);
    songList.addAll(songListModel.list.obs);
    // print('SongsState数据');
  }
}
